/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfejs;

import java.util.ArrayList;
import java.util.List;
import sun.nio.cs.ext.GB18030;

/**
 *
 * @author Tomek
 */
public class GameWelcome extends javax.swing.JPanel{

    /**
     * Creates new form GameWelcome
     */
    List<String> helpList = new ArrayList<String>();
    int helpIndex = 0;
    int helpIndexMax = 0;
    Game obiektGry;
    
    public static javax.swing.JPanel panelGlowny;
    public GameWelcome() {
        initComponents();
        createHelp();
        this.setBounds(0, 0, 480, 640);
        this.setVisible(false);
        Game.panelGlowny.add(this);
    }

    
    public void LoadScreenWelcome()
    {
        this.setVisible(true);
        //Game.panelGlowny.validate();
        Game.panelGlowny.repaint();
    }
    
    public void UnLoadScreenWelcome()
    {
        this.setVisible(false);
        //Game.panelGlowny.validate();
        Game.panelGlowny.repaint();
    }
        
    private void createHelp(){
        helpList.add("<html>Celem gry jest pozbycie się (zbicie) wszystkich pionków należących do przeciwnika <br>"
                + "(w tym także damek) albo zablokowanie rywala tak, by nie mógł on wykonać żadnego ruchu. <br>"
                + "Drugi wariant daje z pewnością więcej satysfakcji, a szczególnie w przypadku, kiedy graczowi <br>"
                + "uda się zablokować przeciwnikowi damkę. Charakterystycznym elementem dla gry w <br>"
                + "warcaby jest właśnie dążenie pionka do przemiany w damkę. W przeciwieństwie do <br>"
                + "szachów, gdzie gra często  kończy się bez promocji choćby nawet jednego pionka, to w <br> "
                + "warcabach jest to praktycznie niemożliwe...  </html>");
        
            helpList.add("<html>Dlatego więc wiele kombinacji na planszy ma za cel doprowadzić pionek na pole <br>"
                    + "przemiany w damkę. Pierwszy ruch należy do zawodnika posiadającego pionki białe, po<br>"
                    + " czym następne ruchy gracze wykonują na przemian.</html>");
            jLabel6.setText(helpList.get(helpIndex));
            helpIndex++;  
            helpIndexMax = helpList.size();
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setMaximumSize(new java.awt.Dimension(480, 640));
        setMinimumSize(new java.awt.Dimension(480, 640));
        setPreferredSize(new java.awt.Dimension(480, 640));
        setRequestFocusEnabled(false);
        setLayout(null);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/import/graph/logo2.jpg"))); // NOI18N
        add(jLabel2);
        jLabel2.setBounds(30, 10, 415, 230);

        jButton2.setText("wiecej...");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel6.setPreferredSize(new java.awt.Dimension(400, 60));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton2))
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addGap(6, 6, 6))
        );

        jLabel6.getAccessibleContext().setAccessibleName("lblHelp");

        add(jPanel1);
        jPanel1.setBounds(20, 240, 440, 160);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/import/graph/warcaby.jpg"))); // NOI18N
        add(jLabel1);
        jLabel1.setBounds(0, 510, 480, 135);

        jLabel3.setText("Gracz biały");
        jLabel3.setMaximumSize(new java.awt.Dimension(40, 15));
        jLabel3.setMinimumSize(new java.awt.Dimension(40, 15));
        jLabel3.setPreferredSize(new java.awt.Dimension(40, 15));

        jTextField1.setText("Roman");
        jTextField1.setMaximumSize(new java.awt.Dimension(6, 100));
        jTextField1.setMinimumSize(new java.awt.Dimension(6, 100));

        jTextField2.setText("Sylwia");
        jTextField2.setMaximumSize(new java.awt.Dimension(40, 15));
        jTextField2.setMinimumSize(new java.awt.Dimension(40, 15));
        jTextField2.setPreferredSize(new java.awt.Dimension(40, 15));

        jButton1.setText("START");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel4.setText("Gracz czarny");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(24, 24, 24))
        );

        add(jPanel2);
        jPanel2.setBounds(20, 410, 440, 80);

        getAccessibleContext().setAccessibleName("GameWelcome");
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
            if(helpIndex<helpIndexMax){
                jLabel6.setText(helpList.get(helpIndex));
                helpIndex++;
            }
            else
            {
                helpIndex=0;
                jLabel6.setText(helpList.get(helpIndex));
                helpIndex++;
            }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Game.gpObj = new GamePlay();
        Game.gpObj.LoadScreenPlay();
        Game.gwObj.UnLoadScreenWelcome();
        
    }//GEN-LAST:event_jButton1ActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
}
